<?php

define('NOT_FROM_DELETE_USER',true);
require_once(CONTROLLER_PATH.'delete-status.php');

function delete_user($user_id) {
	// delete follower, following orang ini
	// delete mentions ke orang ini
	// panggil fungsi delete status
	// delete usernya
	$statuses = db_array('SELECT stat_id FROM status WHERE stat_user = '.$user_id);
	foreach ($statuses as $status) {
		delete_status($status['stat_id']);
	}
	db_query('DELETE FROM follow WHERE user_by = '.$user_id.' OR user_who = '.$user_id);
	db_query('DELETE FROM users WHERE user_id = '.$user_id);
}

if ($session['user']['role'] == '2' && defined('NO_DIRECT')) {
	if (isset($_GET['i'])) {
		$delete_id = intval($_GET['i']);
		$user = db_result('SELECT user_id FROM users WHERE user_id = '.$delete_id);
		if ($user === false) {
			// gagal. hapus user yg ga nyata
		} else {
			if ($session['user']['user_id'] == $user['user_id']) {
				// jangan woy lu mau ngapus diri sendiri min
			} else {
				delete_user($user['user_id']);
				// berhasil oye oye
			}
		}
	}
}
